﻿using AconITF.Core.Models;
using AconITF.Windows;
using PTA.Until;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AconITF.Common
{
	public class GlobalData
	{
		static GlobalData()
		{
			LoadConfig();
		}

		const string VAR_FILE_PATH = ".\\Configs\\变量列表.xlsx";

		/// <summary>
		/// 所有变量的字典
		/// </summary>
		public static Dictionary<string, VariableItem> AllVars { get; set; } = new Dictionary<string, VariableItem>();

		private static void LoadConfig()
		{
			var varList = ExcelHelper.ReadVarList(VAR_FILE_PATH);
			foreach (var item in varList)
			{
				AllVars.Add(item.Name, item);
			}
		}

		private static PowerControl powerWinInstance;

		public static PowerControl PowerWinInstance
		{
			get
			{
				if (powerWinInstance == null)
				{
					powerWinInstance = new PowerControl();
					powerWinInstance.Owner = App.Current.MainWindow;
				}
				return powerWinInstance;
			}
			set { powerWinInstance = value; }
		}
	}
}
